package com.ruoyi.web.controller.books;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.books.domain.BooksProjectFeatures;
import com.ruoyi.books.service.IBooksProjectFeaturesService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 非遗项目特色Controller
 *
 * @author ruoyi
 * @date 2024-03-31
 */
@Anonymous
@RestController
@RequestMapping("/books/features")
public class BooksProjectFeaturesController extends BaseController
{
    @Autowired
    private IBooksProjectFeaturesService booksProjectFeaturesService;

    /**
     * 查询非遗项目特色列表
     */
//    @PreAuthorize("@ss.hasPermi('books:features:list')")
    @GetMapping("/list")
    public TableDataInfo list(BooksProjectFeatures booksProjectFeatures)
    {
        startPage();
        List<BooksProjectFeatures> list = booksProjectFeaturesService.selectBooksProjectFeaturesList(booksProjectFeatures);
        return getDataTable(list);
    }

    /**
     * 导出非遗项目特色列表
     */
//    @PreAuthorize("@ss.hasPermi('books:features:export')")
    @Log(title = "非遗项目特色", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BooksProjectFeatures booksProjectFeatures)
    {
        List<BooksProjectFeatures> list = booksProjectFeaturesService.selectBooksProjectFeaturesList(booksProjectFeatures);
        ExcelUtil<BooksProjectFeatures> util = new ExcelUtil<BooksProjectFeatures>(BooksProjectFeatures.class);
        util.exportExcel(response, list, "非遗项目特色数据");
    }

    /**
     * 获取非遗项目特色详细信息
     */
//    @PreAuthorize("@ss.hasPermi('books:features:query')")
    @GetMapping(value = "/{projectFeaturesId}")
    public AjaxResult getInfo(@PathVariable("projectFeaturesId") Long projectFeaturesId)
    {
        return success(booksProjectFeaturesService.selectBooksProjectFeaturesByProjectFeaturesId(projectFeaturesId));
    }

    /**
     * 新增非遗项目特色
     */
//    @PreAuthorize("@ss.hasPermi('books:features:add')")
    @Log(title = "非遗项目特色", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BooksProjectFeatures booksProjectFeatures)
    {
        return toAjax(booksProjectFeaturesService.insertBooksProjectFeatures(booksProjectFeatures));
    }

    /**
     * 修改非遗项目特色
     */
//    @PreAuthorize("@ss.hasPermi('books:features:edit')")
    @Log(title = "非遗项目特色", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BooksProjectFeatures booksProjectFeatures)
    {
        return toAjax(booksProjectFeaturesService.updateBooksProjectFeatures(booksProjectFeatures));
    }

    /**
     * 删除非遗项目特色
     */
//    @PreAuthorize("@ss.hasPermi('books:features:remove')")
    @Log(title = "非遗项目特色", businessType = BusinessType.DELETE)
	@DeleteMapping("/{projectFeaturesIds}")
    public AjaxResult remove(@PathVariable Long[] projectFeaturesIds)
    {
        return toAjax(booksProjectFeaturesService.deleteBooksProjectFeaturesByProjectFeaturesIds(projectFeaturesIds));
    }
}
